package com.example.lastwork.dao;


import com.example.lastwork.common.dao.LogicDAO;
import com.example.lastwork.entity.Customer;
import com.example.lastwork.entity.Orders;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface CustomerDao extends LogicDAO<Customer, Long> {
    @Modifying
    @Query("UPDATE Orders o SET o.status = 1 WHERE o.id = :ordersId AND o.status = 0")
    int payment(@Param(value = "ordersId") Long ordersId);

    @Query("SELECT o FROM Orders o WHERE o.customer.id = :customerId")
    List<Orders> getOrdersByCustomerId(@Param(value = "customerId") Long customerId);
}
